/*s akkor az lenne a feladat h azon rabok
kozul akiket gyilkossagert iteltek el azoknak
akiknek a buntetesi ideje kevesebb mint 10 ev
modositsuk 10 evre a buntetest*/

create procedure rab_buntetes as

declare @kod int,@ido int

begin transaction
set transaction isolation level serializable

declare c cursor for
select r.id,r.bunt_ido
from rab r,rabbunteny n,bunteny b
where r.id=n.rab_id and n.bunteny_id=b.id and b.nev='gyilkossag'

open c
fetch next from c into @kod,@ido
while @@fetch_status=0
begin
if @ido<10
begin
update rab set bunt_ido=10 where id=@kod
if @@error<>0 rollback transaction
end
fetch next from c into @kod,@ido
end
close c
deallocate c

commit transaction